package com.minke.springboot.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author 何杨谊
 * @description: TODO
 * @date 2022/4/2 17:59
 */
@RestController
@RequestMapping("/api/redis")
public class RedisController {

    @Resource
    private RedisTemplate<Object,Object> redisTemplate;

    @GetMapping
    public Object Get(String key) {
        return redisTemplate.opsForValue().get(key);
    }

    @PutMapping
    public Object put(String key,String value){
        redisTemplate.opsForValue().set(key,value);
        return redisTemplate.opsForValue().get(key);
    }
}
